unit FormControle;

interface

uses
  MVCInterfaces, Multiplicacao, Visao1;

type
  TFormControle = class(TInterfacedObject, IControle)
    private
      FVisao: TVisao;
      FModel: TModeloMultiplicacao;
    public
      constructor Create; reintroduce;
      destructor Destroy; override;
      procedure Initialize;
      procedure Calcular;
  end;

implementation

{ TFormControle }

procedure TFormControle.Calcular;
begin
  FModel.Multiplicacao;
end;

constructor TFormControle.Create;
begin
  FModel := TModeloMultiplicacao.Create;
  FVisao := TVisao.Create(nil);
end;

destructor TFormControle.Destroy;
begin
  FVisao.Free;
  inherited;
end;

procedure TFormControle.Initialize;
begin
  FVisao.Model := FModel;
  FModel.OnModelChanged := FVisao.ModelChanged;
  FVisao.FazCalculo := Calcular;
  FVisao.Initialize;
  FVisao.ShowModal;
end;

end.
 